package com.adams.dcxt.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.adams.dcxt.bean.Order;
import com.adams.dcxt.core.Contants;
import com.adams.dcxt.dao.OrderDao;

@Service("orderService")
public class OrderServiceImpl implements OrderService {
    
    @Autowired
    private  OrderDao  orderDao ;
    @Override
    public Order queryOrderByTable(String table) {
        Order order = null;
        String hql =  " from Order where table = ? and status = ?  order by  orderTime desc" ;
        List<Order>   list = orderDao.query(hql, table,Contants.ORDER_NO_CHECK);
        if(list!=null){
            if(!list.isEmpty()){
                order  =  list.get(0);
            }
        }
        return order;
    }
    @Transactional
    @Override
    public Long saveOrder(Order o) {
        orderDao.save(o); 
        return o.getId();
    }

}
